var swiper = new Swiper('.swiper-container', {
    autoplay: {
        delay: 5000,
        stopOnLastSlide: false,
        disableOnInteraction: true,
    }, //等同于以下设置
    loop: true,
    slidesPerView: 'auto',
    spaceBetween: 30,
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
    on: {
        slideChangeTransitionStart: function() {
            $('.banner-bimg').addClass('animated fadeInLeft')
            $('.banner-img').addClass('animated fadeInRight')
            $('.banner-title').addClass('animated fadeInUp')
            $('.banner-img').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpTitle);
        },
        slideChange: function() {
            $('.banner-bimg').removeClass('animated fadeInLeft')
            $('.banner-img').removeClass('animated fadeInRight')
            $('.banner-title').removeClass('animated fadeInUp')
            $('.banner-title').hide()
        },
        resize: function() {
            hight();
        }
    },
});

$(function() {
    var hight = $('.banner-img img').css('height');
    $('.banner-bimg img').css('height', hight);
})

function fadeInUpTitle() {
    $('.banner-title').show();
    $('.banner-title').addClass('animated fadeInUp')
}

function hight() {
    var hight = $('.banner-img img').css('height');
    $('.banner-bimg img').css('height', hight);
}

// 返回顶部
function goTop() {
    $('html, body').animate({ scrollTop: 0 }, 'slow');
}

// web/app/ai  个人资料
var once = 0;

function about() {
    if (once === 0) {
        fadeInUp()
        $(".about-rg-top h5").css('visibility', 'hidden');
        $(".about-rg-top h6").css('visibility', 'hidden');
        $(".about-rg-top p").css('visibility', 'hidden');
        $(".about-rg-bottom ul").css('visibility', 'hidden');
        $(".about-skills").css('visibility', 'hidden');
        flipInX()
        once++
    }
}

$('#scroll-one').waypoint({
    handler: function(direction) {
        if (direction === 'down' && once === 0) {
            fadeInUp()
            $(".about-rg-top h5").css('visibility', 'hidden');
            $(".about-rg-top h6").css('visibility', 'hidden');
            $(".about-rg-top p").css('visibility', 'hidden');
            $(".about-rg-bottom ul").css('visibility', 'hidden');
            $(".about-skills").css('visibility', 'hidden');
            flipInX()
            once++
        }
    }
})

function fadeInUp() {
    $(".terminal .content").addClass('animated fadeInUp');
}

function flipInX() {
    $(".about").addClass('animated flipInX');
    $('.about').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpOne);
}

function fadeInUpOne() {
    $(".about-rg-top h5").css('visibility', 'visible');
    $(".about-rg-top h5").addClass('animated fadeInUp');
    $('.about').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpTwo);
}

function fadeInUpTwo() {
    $(".about-rg-top h6").css('visibility', 'visible');
    $(".about-rg-top h6").addClass('animated fadeInUp');
    $('.about').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpThree);
}

function fadeInUpThree() {
    $(".about-rg-top p").css('visibility', 'visible');
    $(".about-rg-top p").addClass('animated fadeInUp');
    $('.about').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpFour);
}

function fadeInUpFour() {
    $(".about-rg-bottom ul").css('visibility', 'visible');
    $(".about-rg-bottom ul").addClass('animated fadeInUp');
    $('.about').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInUpFive);
}

function fadeInUpFive() {
    $(".about-skills").css('visibility', 'visible');
    $(".about-skills").addClass('animated fadeInUp');
}

// 参与项目
var one = 0

function project() {
    if (one === 0) {
        $(".project-lf h5").css('visibility', 'hidden');
        $(".project-lf h6").css('visibility', 'hidden');
        $(".project-lf ul").css('visibility', 'hidden');
        fadeInLeft()
        one++
    }
}

$('.terminal-line').waypoint({
    handler: function(direction) {
        if (direction === 'down' && one === 0) {
            $(".project-lf h5").css('visibility', 'hidden');
            $(".project-lf h6").css('visibility', 'hidden');
            $(".project-lf ul").css('visibility', 'hidden');
            fadeInLeft()
            one++
        }
    }
})

function fadeInLeft() {
    $(".project-rg img").addClass('animated fadeInLeft');
    $('.project-rg img').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInLeftOne);
}

function fadeInLeftOne() {
    $(".project-lf h5").css('visibility', 'visible');
    $(".project-lf h5").addClass('animated fadeInUp');
    $(".project-lf h6").css('visibility', 'visible');
    $(".project-lf h6").addClass('animated fadeInUp');
    $(".project-lf ul").css('visibility', 'visible');
    $(".project-lf ul").addClass('animated fadeInUp');
    // $('.project-lf h5').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInLeftTwo);
}

function fadeInLeftTwo() {
    $(".project-lf h6").css('visibility', 'visible');
    $(".project-lf h6").addClass('animated fadeInUp');
    $(".project-lf ul").css('visibility', 'visible');
    $(".project-lf ul").addClass('animated fadeInUp');
    // $('.project-lf h6').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', fadeInLeftThree);
}

function fadeInLeftThree() {
    $(".project-lf ul").css('visibility', 'visible');
    $(".project-lf ul").addClass('animated fadeInUp');
}

// 作品集
var worksonce = 0;

function works() {
    if (worksonce === 0) {
        var i;
        var start;
        start = 1
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        setTimeout(() => {
            for (i = start; i < 25; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
            $(".image-list").css('height', '342px');
            $("#loadMore").show();
            $("#loadMore").addClass('animated fadeInRight');
        }, 300);
        worksonce++
    }
}

$('.about-rg-top h6').waypoint({
    handler: function(direction) {
        if (direction === 'down' && worksonce === 0) {
            var i;
            var start;
            start = 1
            for (i = 1; i < 25; i++) {
                $('#' + i).hide()
            }
            setTimeout(() => {
                for (i = start; i < 25; i++) {
                    $('#' + i).show();
                    $('#' + i).addClass('animated fadeInRight');
                }
                $(".image-list").css('height', '342px');
                $("#loadMore").show();
                $("#loadMore").addClass('animated fadeInRight');
            }, 300);
            worksonce++
        }
    }
})


// load more
$("#loadMore").on('click', function() {
    $(".works-img ul").animate({ "height": "1028px" }, 800);
    $("#loadMore").fadeOut(1000)
})

// tab
function tab(number, e) {
    $("#tabimg li span").removeClass('active')
    $(e).addClass("active");
    var i;
    var start;
    if (number === 0) {
        start = 1
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        setTimeout(() => {
            for (i = start; i < 25; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
            $(".image-list").css('height', '342px');
            $("#loadMore").show();
            $("#loadMore").addClass('animated fadeInRight');
        }, 300);
    }
    if (number === 1) {
        start = 3
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        $(".image-list").css('height', '342px');
        $("#loadMore").hide()
        setTimeout(() => {
            for (i = start; i < 10; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
        }, 300);
    }
    if (number === 2) {
        start = 10
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        $(".image-list").css('height', '342px');
        $("#loadMore").hide()
        setTimeout(() => {
            for (i = start; i < 16; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
        }, 300);

    }
    if (number === 3) {
        start = 16
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        $(".image-list").css('height', '342px');
        $("#loadMore").hide()
        setTimeout(() => {
            for (i = start; i < 21; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
        }, 300);
    }
    if (number === 4) {
        start = 20
        for (i = 1; i < 25; i++) {
            $('#' + i).hide()
        }
        $(".image-list").css('height', '342px');
        $("#loadMore").hide()
        setTimeout(() => {
            for (i = start; i < 25; i++) {
                $('#' + i).show();
                $('#' + i).addClass('animated fadeInRight');
            }
        }, 300);
    }
}


// 技能熟练度
var first = 0

function skills() {
    if (first === 0) {
        $(".skill-rg h5").css('visibility', 'hidden');
        $(".skill-rg ul").css('visibility', 'hidden');
        $(".skill-rg p").css('visibility', 'hidden');
        rollIn()
        first++
    }
}

$('#skills').waypoint({
    handler: function(direction) {
        if (direction === 'down' && first === 0) {
            $(".skill-rg h5").css('visibility', 'hidden');
            $(".skill-rg ul").css('visibility', 'hidden');
            $(".skill-rg p").css('visibility', 'hidden');
            rollIn()
            first++
        }
    }
})

function rollIn() {
    $(".skill-lf img").addClass('animated rollIn');
    $('.skill-lf img').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', rollInOne);
}

function rollInOne() {
    $(".skill-rg h5").css('visibility', 'visible');
    $(".skill-rg h5").addClass('animated fadeInUp');
    $('.skill-rg h5').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', rollInTwo);
}

function rollInTwo() {
    $(".skill-rg ul").css('visibility', 'visible');
    $(".skill-rg ul").addClass('animated fadeInUp');
    $('.skill-rg ul').one('webkitAnimationEnd mozAnimationEnd MSAnimationEnd oanimationend animationend', rollInThree);
}

function rollInThree() {
    $(".skill-rg p").css('visibility', 'visible');
    $(".skill-rg p").addClass('animated fadeInUp');
}

// Top
$(function() {
    $(window).scroll(function() {
        if ($(window).scrollTop() >= 400) {
            $('.scrollTop').fadeIn(400);
        } else {
            $('.scrollTop').fadeOut(400);
        }
    });
    $('.scrollTop').click(function() {
        $('html,body').animate({ scrollTop: '0px' }, 100);
    });
})

// 作品集
function imgbox(start) {
    var json = {
        "title": "作品集", //相册标题
        "id": 1, //相册id
        "start": start, //初始显示的图片序号，默认0
        "data": [ //相册包含的图片，数组格式
            {
                "alt": "",
                "pid": 0, //图片id
                "src": "images/works/1.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 1, //图片id
                "src": "images/works/2.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 2, //图片id
                "src": "images/works/3.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 3, //图片id
                "src": "images/works/4.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 4, //图片id
                "src": "images/works/5.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 5, //图片id
                "src": "images/works/6.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 6, //图片id
                "src": "images/works/7.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 7, //图片id
                "src": "images/works/8.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 8, //图片id
                "src": "images/works/9.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 9, //图片id
                "src": "images/works/10.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 10, //图片id
                "src": "images/works/11.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 11, //图片id
                "src": "images/works/12.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 12, //图片id
                "src": "images/works/13.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 13, //图片id
                "src": "images/works/14.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 14, //图片id
                "src": "images/works/15.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 15, //图片id
                "src": "images/works/16.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 16, //图片id
                "src": "images/works/17.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 17, //图片id
                "src": "images/works/18.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 18, //图片id
                "src": "images/works/19.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 19, //图片id
                "src": "images/works/20.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 20, //图片id
                "src": "images/works/21.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 21, //图片id
                "src": "images/works/22.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 22, //图片id
                "src": "images/works/23.jpg", //原图地址
                "thumb": "" //缩略图地址
            }, {
                "alt": "",
                "pid": 23, //图片id
                "src": "images/works/24.jpg", //原图地址
                "thumb": "" //缩略图地址
            }
        ]
    }
    layer.photos({
        photos: json, //格式见API文档手册页
        anim: 5 //0-6的选择，指定弹出图片动画类型，默认随机
    });
}